package tcards.android;

import models.CrewTcard;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;

public class PeopleFieldList extends LinearLayout {
	private YesNoField  mManifest;
	private NumberField mTotalWeight;
	private TextField   mMethodOfTravel;
	private TextField   mTransportation;
	
	public PeopleFieldList(Context context) {
		this(context, null, 0);
	}

	public PeopleFieldList(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}

	public PeopleFieldList(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		LayoutInflater li = LayoutInflater.from(context);
		addView(li.inflate(R.layout.people_field_list, this, false));
		
		mManifest       = (YesNoField)  findViewById(R.id.manifestField);
		mTotalWeight    = (NumberField) findViewById(R.id.totalWeightField);
		mMethodOfTravel = (TextField)   findViewById(R.id.methodOfTravelField);
		mTransportation = (TextField)   findViewById(R.id.transportationField);
	}
	
	public void setTcardFields(CrewTcard tcard) {
		tcard.setManifest(mManifest.getValue());
		tcard.setTotalWeight(mTotalWeight.getNumberValue());
		tcard.setTravelMethod(mMethodOfTravel.getTextValue());
		tcard.setTransportationNeeds(mTransportation.getTextValue());
	}
	
	public void setListFields(CrewTcard tcard) {
		mManifest.setValue(tcard.isManifest());
		mTotalWeight.setNumberValue(tcard.getTotalWeight());
		mMethodOfTravel.setTextValue(tcard.getTravelMethod());
		mTransportation.setTextValue(tcard.getTransportationNeeds());
	}
	
	public YesNoField getManifest() {
		return mManifest;
	}
	
	public NumberField getTotalWeight() {
		return mTotalWeight;
	}
	
	public TextField getMethodOfTravel() {
		return mMethodOfTravel;
	}
	
	public TextField getTransportation() {
		return mTransportation;
	}
}